package cn.yeziji.forum.common.enums;

import cn.yeziji.forum.utils.BasicEnumAnalyzeUtils;
import cn.yeziji.forum.common.BasicEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 论坛 level 枚举
 *
 * @author hwy
 * @since 2023/07/11 9:44
 **/
@Getter
@AllArgsConstructor
public enum ForumLevelEnum implements BasicEnum {
  /** code：编码，value 每个阶级的经验乘积 */
  ONE(1, "第 1 阶级", 10),
  TWO(2, "第 2 阶级", 12),
  THIRD(3, "第 3 阶级", 13),
  FOUR(4, "第 4 阶级", 15),
  FIVE(5, "第 5 阶级", 20),
  ;
  final int code;
  final String desc;
  final Object value;

  @Override
  public ForumLevelEnum getByCode(int code) {
    return (ForumLevelEnum) BasicEnumAnalyzeUtils.getInstance(this.getClass()).getByCode(code);
  }

  @Override
  public ForumLevelEnum getByDesc(String desc) {
    return (ForumLevelEnum) BasicEnumAnalyzeUtils.getInstance(this.getClass()).getByDesc(desc);
  }

  @Override
  public Enum getByValue(Object value) {
    return (ForumLevelEnum) BasicEnumAnalyzeUtils.getInstance(this.getClass()).getByValue(value);
  }

  @Override
  public boolean hasCode(int code) {
    return getByCode(code) != null;
  }

  @Override
  public boolean hasDesc(String desc) {
    return getByDesc(desc) != null;
  }

  @Override
  public boolean hasValue(Object value) {
    return false;
  }
}
